/**
 * 基础菜单 商品管理
 */
<template>
<div>
  <!-- 面包屑导航 -->
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/main' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item :to="{ path: '/farmer/auditList' }">审核列表</el-breadcrumb-item>
    <el-breadcrumb-item>审核详情</el-breadcrumb-item>
  </el-breadcrumb>
  <setUp title="审核信息">
    <div style="margin: 0 auto;">
      <el-button type="danger" :loading="loading_confirm" @click="rejects('AUDIT_PASS')">审核拒绝</el-button>
      <el-button type="primary" :loading="loading_confirm" @click="approved('AUDIT_PASS')">审核通过</el-button>
    </div>
  </setUp>
  <setUp title="个人信息">
    <div style="margin: 0 auto;">
      <el-form ref="form" label-width="150px" :model="form" style="display:flex;width:1200px;flex-wrap:wrap">
        <my-input label="姓名" :placeholder="placeholder" v-model="form.name" prop="name"></my-input>
        <my-input label="性别" :placeholder="placeholder" v-model="sexOptions[form.sex]" prop="sex"></my-input>
        <my-input label="出生日期" :placeholder="placeholder" v-model="form.bornDate" prop="bornDate"></my-input>
        <my-input label="身份证号" :placeholder="placeholder" v-model="form.idCard" prop="idCard"></my-input>
        <my-input label="联系电话" :placeholder="placeholder" v-model="form.mobile" prop="mobile"></my-input>
        <my-input label="联系地址" :placeholder="placeholder" v-model="form.address" prop="address"></my-input>
        <my-input label="籍贯" :placeholder="placeholder" v-model="form.nativePlace" prop="nativePlace" readonly />
        <my-input label="民族" :placeholder="placeholder" v-model="form.national" prop="national"></my-input>
        <my-input label="邮箱" :placeholder="placeholder" v-model="form.email" prop="email"></my-input>
        <myFormItem label="审核状态" class="status-style">
          <template>
            <div style="width:200px;font-weight: 700;">{{ auditOptions[form.auditStatus]}}</div>
          </template>
        </myFormItem>
      </el-form>
    </div>
  </setUp>
  <setUp title="农场信息">
    <div style="margin: 0 auto;">
      <el-form ref="form" label-width="150px" :model="form" style="display:flex;width:1200px;flex-wrap:wrap">
        <my-input label="农场地址" :placeholder="placeholder" v-model="form.farmAddress" prop="farmAddress"></my-input>
        <my-input label="农作物类型" :placeholder="placeholder" v-model="form.cropType" prop="cropType"></my-input>
        <my-input label="备注" :placeholder="placeholder" v-model="form.remark" prop="remark"></my-input>
      </el-form>
    </div>
  </setUp>
</div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        auditStatus: "AUDIT_PASS",
      },
      placeholder: "暂无填写",
      sexOptions: {
        1: "男",
        2: "女",
      },
      auditOptions: {
        AUDIT_PASS: "审核通过",
        AUDIT_FAIL: "审核不通过",
        NOT_AUDIT: "待审核",
      },
      loading_confirm: false,
    };
  },
  // 注册组件
  components: {},
  methods: {
    approved(arg) {
      this.$confirm("确定进行此操作吗？", "提示")
        .then(async () => {
          this.patchStatus(arg);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    rejects(arg) {
      this.$confirm("确定进行此操作吗？", "提示")
        .then(async () => {
          this.patchStatus(arg);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    async patchStatus(arg) {
      this.loading_confirm = true;
      try {
        // await this.requestApi.patchAuditStatus(this.form.id, {
        //   auditStatus: arg
        // })
        // this.getItemById()
        this.loading_confirm = false;
        this.$message.success("更新成功");
      } catch {
        this.loading_confirm = false;
        this.$message.warning("更新失败");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .status-style {
  color: red !important;

  .el-form.refereeCertificate-item__label {
    color: red !important;
  }
}
</style>
